<template>
	<view class="cart">
		<view
			class="category-list"
			>
		<!-- 表头 -->
		<scroll-view scroll-x="true" class="left">
			<view style="display: flex;">
				<view
					class="row"
					:class="[0 === showCategoryIndex ? 'on' : '']"
					@tap="showCategory(0)"
				>
					<view class="text" style="display: flex;">
						<!-- <view class="block" :class="'bg-'+themeColor.name"></view> -->
						推荐
					</view>
				</view>
				<view
					class="row"
					:class="[1 === showCategoryIndex ? 'on' : '']"
					@tap="showCategory(1)"
				>
					<view class="text" style="display: flex;">
						<!-- <view class="block" :class="'bg-'+themeColor.name"></view> -->
						排行榜
					</view>
				</view>
			</view>
		</scroll-view>
		
		<!--下方导航-->
		<scroll-view scroll-y="true" class="right">
			<view>
				<view
					v-if="0 === showCategoryIndex"
					class="category">
					
					
					<!-- 瀑布流 -->
					<view class="Index">
							<!-- 瀑布流布局列表 -->
							<view class="pubuBox">
								<view class="pubuItem">
									<view class="item-masonry" v-for="(item, index) in comList" @click="gotodetail(item.id)" :key="index">
										<image v-if="item.cover!=null" :src="item.cover" mode="widthFix"></image>
										<image v-else src="/static/zwpic.png" mode="widthFix"></image>
										<view class="listtitle"> <!-- 这是没有高度的父盒子（下半部分） -->
											<view class="listtitle1">{{ item.name }}</view>
											<view class="listtitle2">
												{{ item.author }}
											</view>
											<view class="listtitle3" style="float: right;margin-right: 10rpx;">
												<span><img width="20rpx" src="/static/like.jpg"/></span>{{item.praise}}
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
					
										
				</view>
				
				<view
					v-if="1 === showCategoryIndex"
					class="category">
					<view class="toptop" style="display: flex;flex-direction: column;">
						<view style="flex-grow:1;color: aliceblue;text-align: center;font-size: 50rpx;">总排名</view>
						<view style="display: flex;align-items: end;">
							<!-- 第二 -->
							<view style="flex-grow: 4;">
								<!-- 头像 -->
								<view class="zttx">
									<view>
										<img src="/static/tm.png" width="20" alt="" srcset="" />
										<text>{{userrank[1].praise}}</text>
									</view>
									<view>
										<img width="60" height="60" style="border-radius: 50%;object-fit:cover;" :src="userrank[1].userImage" alt="" srcset="" />
									</view>
								</view>
								<view class="yjjb" style="font-size: 120rpx;">
									<!-- 名次 -->
									2
								</view>
							</view>
							<!-- 第一-->
							<view style="flex-grow: 5;">
								<!-- 头像 -->
								<view class="zttx">
									<view>
										<img src="/static/tm.png" width="20" alt="" srcset="" />
										<text>{{userrank[0].praise}}</text>
									</view>
									<view>
										<img width="60" height="60" style="border-radius: 50%;object-fit:cover;" :src="userrank[0].userImage==null?'/static/s.png':userrank[0].userImage" alt="" srcset="" />
									
									</view>
								</view>
								<view class="yjjb" style="font-size: 140rpx;">
									<!-- 名次 -->
									1
								</view>
							</view>
							<!-- 第三-->
							<view style="flex-grow: 3;">
								<!-- 头像 -->
								<view class="zttx">
									<view>
										<img src="/static/tm.png" width="20" alt="" srcset="" />
										<text>{{userrank[2].praise}}</text>
									</view>
									<view>
										<img width="60" height="60" style="border-radius: 50%;object-fit:cover;" :src="userrank[2].userImage" alt="" srcset="" />
									</view>
								</view>
								<view class="yjjb" style="font-size: 100rpx;">
									<!-- 名次 -->
									3
								</view>
							</view>
						</view>
					</view>
					
					<!-- 剩余排名 -->
					<view style="padding: 0 30rpx 0 30rpx;">
						<view style="color: #999;">
							<view style="float: left;font-size: 21rpx;">如何快速上榜?</view>
							<view style="float: right;font-size: 21rpx;">获赞数量</view>
						</view>
						
						<view style="" v-for="(item,index) in userrank">
							<view  style="clear: both;display: flex;flex-direction: row;align-items: center; margin-top: 10px;">
								<view class="" style="display: flex; justify-content: center;align-items: center;">
									<text style="margin-right: 10px;">{{index+1}}</text>
									<img width="40" height="40" style="border-radius: 50%;object-fit: cover;" :src="item.userImage" />
									<text style="margin-left: 20px;">{{item.userName}}</text>
								</view>
								
								<view style="flex-grow: 1;"></view>
								
								<view style="">
									<img src="/static/tm.png" width="20" alt="" srcset="" />
									<text>{{item.praise}}</text>
								</view>
							</view>
						</view>
						
					</view>
					
					
				</view>
			</view>
		</scroll-view>
		{{typee}}
		</view>
		
	</view>
</template>
<script>
// const app = getApp();
import {getAllzpj,getRanking,getCtwh} from "@/api/cart.js"
export default {
	data() {
		return {
			showCategoryIndex: 0,
			comList: [], //商品列表
			userrank:[],//全部用户排名
			typee:''
		};
	},
	onShow() {
		// if(this.$store.state.cultureLimit){
		// 	this.initData2(this.$store.state.cultureName);
		// }else{
			this.initData();
		// }
	},
	onTabItemTap() {
			// 您点击了“导航”页...
			// this.$store.state.cultureLimit=false;
		},
	methods: {
		// 您点击了“导航”页
		onTabItemTap() {
			// this.$store.state.cultureLimit=false;
		},
		// 数据初始化
		async initData() {
			let res = await getAllzpj();
			this.comList=res.data.data;
			// 获取排名
			const res2 = await getRanking();
			this.userrank = res2.data.data;
			console.log(this.userrank);
		},
		async initData2(name) {
			const res = await getCtwh(name);
			// this.idd=res.data.id;
			this.comList=res.data.data;
			const res2 = await getRanking();
			this.userrank = res2.data.data;
			console.log(this.userrank);
		},
		showCategory(index) {
			this.showCategoryIndex = index;
		},
		gotodetail(index){
			uni.navigateTo({
				url:'/pages/zpdetail/zpdetail?id='+index
			});
		}
	}
};

</script>
<style lang="scss">
	page {
		background-color: $color-white;
		height: 100%;
	}
	.yjjb{
		background: linear-gradient(orange, white);
		border-radius: 10% 10% 0 0;
		color: rgba(255, 255, 255, 0.7);
		text-align: center;
		font-size: 120rpx;
	}
	.zttx{
		display: flex;
		flex-direction: column;
		align-items: center;
	}
.cart {
	background-color: $color-white;
	/*  #ifdef  APP-PLUS  */
	margin-top: calc(20upx + var(--status-bar-height));
	/*  #endif  */
	/*模块分类*/
	.category-list {
		width: 100%;
		background-color: #fff;
		// display: flex;
		.left,
		.right {
			// position: absolute;
			// top: 80upx;
			/*  #ifdef  APP-PLUS  */
			top: calc(80upx + var(--status-bar-height));
			/*  #endif  */
			// bottom: 0upx;
			display: flex;
		}

		.left {
			// width: 24%;
			// left: 0upx;
			background-color: $page-color-base;
			display: flex;
			.row {
				width: 100%;
				height: 90upx;
				display: flex;
				align-items: center;

				.text {
					width: 100%;
					position: relative;
					font-size: 28upx;
					display: flex;
					justify-content: center;
					color: #3c3c3c;

					.block {
						position: absolute;
						width: 0upx;
						left: 0;
					}
				}

				&.on {
					height: 100upx;
					background-color: #fff;
					.text {
						font-size: 30upx;
						font-weight: 600;
						color: #2d2d2d;
						.block {
							width: 6upx;
							height: 120%;
							left: 10upx;
						}
					}
				}
			}
		}
		.right {
			width: 100%;
			left: 24%;
			background-color: #fff;
			.second-category {
				z-index: 10;
				white-space: nowrap;
				width: 100%;
				margin: $spacing-sm $spacing-sm $spacing-base;
				.second-category-tag {
					margin-right: $spacing-base;
					padding: 5upx $spacing-lg;
					display: inline-block;
					border-radius: 8upx;
					font-size: $font-sm + 2upx;
				}
				.second-category-normal {
					color: $font-color-dark;
					border: none;
					background-color: $page-color-light;
				}
			}
			.category {
				
				width: 100%;
				padding: 0 15upx $spacing-base;
				.banner {
					width: 96%;
					margin: 10upx auto 30upx;
					height: 24.262vw;
					border-radius: 10upx;
					overflow: hidden;
					box-shadow: 0upx 5upx 20upx rgba(0, 0, 0, 0.05);
					image {
						width: 100%;
						height: 24.262vw;
					}
				}
				.order-by-wrapper {
					height: 48upx;
					line-height: 48upx;
					display: flex;
					justify-content: space-between;
					margin: $spacing-sm 0;
					font-size: $font-sm + 2upx;
					.order-by {
						display: flex;
						justify-content: center;
						align-items: center;
						.order-by-item {
							display: flex;
							justify-content: center;
							align-items: center;
							font-size: $font-sm + 2upx;
							margin: 0 $spacing-base 0 $spacing-sm;
							color: $font-color-light;
							.iconfont-group {
								margin-top: -2upx;
							}
							.iconfont {
								height: 16upx;
								line-height: 16upx;
								display: block;
								margin-left: 6upx;
								font-weight: 550;
								font-size: $font-sm - 4upx;
							}
						}
					}
				}
				.list {
					margin-top: $spacing-base;
					width: 100%;
					display: flex;
					flex-wrap: wrap;
					.box {
						width: calc(71.44vw / 3);
						margin-bottom: $spacing-lg;
						display: flex;
						justify-content: center;
						align-items: center;
						flex-wrap: wrap;
						image {
							width: 64%;
							height: calc(71.44vw / 3 * 0.64);
						}
						.text {
							margin-top: 8upx;
							width: 100%;
							display: flex;
							justify-content: center;
							font-size: 26upx;
						}
						.category-tag {
							width: 100%;
							display: flex;
							justify-content: center;
							align-items: center;
							padding: $spacing-sm;
							font-size: $font-sm + 2upx;
							margin-right: $spacing-base;
							color: $font-color-dark;
							background-color: $page-color-base;
							border-radius: 6upx;
						}
					}
				}
				.second-category-text {
					display: flex;
					justify-content: space-between;
				}
				.no-data {
					margin: 48upx 0;
					color: $font-color-light;
					display: flex;
					justify-content: center;
					align-items: center;

					.iconfont {
						margin-right: 20upx;
						font-size: $font-lg + 16upx;
					}
				}
			}
		}
	}
	.one-cover-category {
		margin-top: $spacing-base;
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		.box {
			width: calc(71.44vw / 3);
			margin-bottom: $spacing-lg;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-wrap: wrap;
			image {
				width: 64%;
				height: calc(71.44vw / 3 * 0.64);
			}
			.text {
				margin-top: 8upx;
				width: 100%;
				display: flex;
				justify-content: center;
				font-size: 26upx;
			}
			.category-tag {
				width: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				padding: $spacing-sm;
				font-size: $font-sm + 2upx;
				margin-right: $spacing-base;
				color: $font-color-dark;
				background-color: $page-color-base;
				border-radius: 6upx;
			}
		}
	}
	.tui-product-container {
		flex: 1;
		margin-right: 10upx;
	}
	.tui-product-container:last-child {
		margin-right: 0;
	}
	.category-product-list {
		margin-bottom: 15upx;
		padding-bottom: 15upx;
		border-bottom: 1upx solid rgba(0, 0, 0, 0.08);
	}
	.category-product-list:last-child {
		border-bottom: none;
		background-color: #007aff;
	}
	.tui-pro-item {
		width: 100%;
		margin-bottom: 20upx;
		background: $color-white;
		box-sizing: border-box;
		border-radius: 12upx;
		overflow: hidden;
		transition: all 0.15s ease-in-out;
	}
	.tui-flex-list {
		display: flex;
		margin-bottom: 1upx !important;
	}
	.tui-pro-img {
		width: 100%;
		display: block;
	}
	.tui-proimg-list {
		width: 160upx;
		height: 160upx !important;
		flex-shrink: 0;
		border-radius: 12upx;
	}
	.tui-pro-content {
		width: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 0 20upx;
	}
	.tui-pro-tit {
		color: #2e2e2e;
		font-size: 26upx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}
	.tui-sale-price {
		font-size: 34upx;
		font-weight: 500;
	}
	.tui-factory-price {
		font-size: 24upx;
		color: #a0a0a0;
		text-decoration: line-through;
		padding-left: 12upx;
	}
	.tui-pro-pay {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 24upx;
		color: #656565;
		.iconfont {
			font-size: $font-lg + 6upx;
			padding: 0 $spacing-sm;
		}
	}
	.popup .layer {
		// #ifndef H5
		bottom: 0;
		// #endif
	}
	.input-box {
		height: 60upx;
		position: relative;
		display: flex;
		align-items: center;
		margin: 10upx 20upx;
		.iconfont {
			width: 60upx;
			font-size: 48upx;
			font-weight: 500;
		}
		.iconsousuo2 {
			z-index: 999;
			display: flex;
			align-items: center;
			position: absolute;
			top: 0;
			right: 0;
			width: 60upx;
			height: 60upx;
			font-size: 34upx;
			color: #c0c0c0;
		}
		input {
			flex: 1;
			height: 60upx;
			background-color: #f5f5f5;
			padding-left: 28upx;
			border-radius: 30upx;
			color: #888;
			font-size: 28upx;
		}
	}
}
.content {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  height: 100vh;
}
// index1
.toptop{
	height: 610rpx;
	background: linear-gradient(orange, white);
}

.pubuBox {
		padding: 22rpx;
	}

	.pubuItem {
		column-count: 2;
		column-gap: 20rpx;
	}

	.item-masonry {
		box-sizing: border-box;
		border-radius: 15rpx;
		overflow: hidden;
		background-color: #fff;
		break-inside: avoid;
		/*避免在元素内部插入分页符*/
		box-sizing: border-box;
		margin-bottom: 20rpx;
		box-shadow: 0px 0px 28rpx 1rpx rgba(78, 101, 153, 0.14);
	}

	.item-masonry image {
		width: 100%;
	}

	.listtitle {
		padding-left: 22rpx;
		font-size: 24rpx;
		padding-bottom: 22rpx;

		.listtitle1 {
			line-height: 39rpx;
			text-overflow: -o-ellipsis-lastline;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			line-clamp: 2;
			-webkit-box-orient: vertical;
			min-height: 39rpx;
			max-height: 78rpx;
		}

		.listtitle2 {
			color: #ff0000;
			font-size: 32rpx;
			line-height: 32rpx;
			font-weight: bold;
			padding-top: 22rpx;

			.listtitle2son {
				font-size: 32rpx;
			}
		}

		.listtitle3 {
			font-size: 28rpx;
			color: #909399;
			line-height: 32rpx;
			padding-top: 22rpx;
		}
	}

	.Index {
		width: 100%;
		height: 100%;
	}
	
</style>
